// 简历历程节点 COURSE_STATES
const COURSE_STATES = {
    '1': {
        // 简历转签
        iconTxt: 'icon-zhuanfa',
        classes: 'course-tran-sign'
    },
    '2': {
        // 面试转签
        iconTxt: 'icon-zhuanfa',
        classes: 'course-tran-sign'
    },
    '3': {
        // 简历反馈
        iconTxt: 'icon-xiaoxi',
        classes: 'course-info'
    },
    '4': {
        // 面试安排
        iconTxt: 'icon-rili',
        classes: 'course-arrage'
    },
    '5': {
        // 面试反馈
        iconTxt: 'icon-xiaoxi',
        classes: 'course-info'
    }
}

// 是否复试状态
const REEXAMINE_STATES = {
    '0': {
        state: 0,
        text: '是',
        tag: true,
    },
    '1': {
        state: 1,
        text: '否',
        tag: false
    },
    '-2': {
        state: '',
        text: '',
        tag: ''
    }
}

// 简历状态
const RESUME_STATES = {
    '0': {
        state: 0,
        stateText: '未入选'
    },
    '1': {
        state: 1,
        stateText: '已入选'
    },
    '2': {
        state: 2,
        stateText: '已入选'
    },
    '3': {
        state: 3,
        stateText: '已入选'
    },
    '4': {
        state: 4,
        stateText: '已入选'
    },
    '5': {
        state: 5,
        stateText: '已入选'
    },
    '-2': {
        state: '',
        text: '',
        tag: ''
    }
}

// 面试状态
const INTERVIEW_STATES = {
    '0': {
        state: 0,
        text: '待安排'
    },
    '1': {
        state: 1,
        text: '已安排'
    },
    '2': {
        state: 2,
        text: '已通过'
    },
    '3': {
        state: 3,
        text: '未通过'
    },
    '4': {
        state: 4,
        text: '待确认',
    },
    '5': {
        state: 5,
        text: '待定'
    },
    '6': {
        state: 6,
        text: '取消面试'
    },
    '-2': {
        state: '',
        text: '',
        tag: ''
    }
}
export function decCourses(courseInfo) {
    if (courseInfo) {
        let cLen = courseInfo.length,
            tempCourse = {},
            tempLefts = {},
            tempRights = {},
            tempStr = '',

            tempData = [],
            tempResumeStateTxt = '',
            tempInterviewStusTxt = '',
            tempInterviewBackTxt = '',
            tempType = '',
            tempState = ''

        for (let i = 0; i < cLen; i++) {
            tempCourse = courseInfo[i]
            let tempStrs = [];
            tempLefts = {
                state: tempCourse.type,
                iconTxt: COURSE_STATES[tempCourse.type].iconTxt,
                classes: COURSE_STATES[tempCourse.type].classes,
                name: tempCourse.sur_name, // 面试官
                time: tempCourse.update_date, // 面试时间
                status: tempCourse.state, // 状态
                creater: tempCourse.creater || ""
            }
            tempType = tempCourse.type.toString();
            tempState = tempCourse.state.toString();
            if (tempType === '4' || tempType === 4) {
                tempInterviewStusTxt = INTERVIEW_STATES[tempState].text;
            }
            if (tempType === '5' || tempType === 5) {
                tempInterviewBackTxt = INTERVIEW_STATES[tempState].text;
            }
            if (tempType === '3' || tempType === 3) {
                tempResumeStateTxt = RESUME_STATES[tempState].stateText;
            }
            if (
                tempCourse.interview_time !== -2 &&
                tempCourse.interview_time.indexOf(',') != -1
            ) {
                tempStrs = tempCourse.interview_time.split(',')
            } else {
                tempStrs.push(tempCourse.interview_time !== -2 ? tempCourse.interview_time : '')
            }
            tempRights = {
                needsCvId: tempCourse.needsCvId, // 需求简历id
                sendee_name: tempCourse.sendee_name, //转签人
                sendee_email: tempCourse.sendee_email, // 邮箱
                sendee_telephone: tempCourse.sendee_telephone, // 电话
                type: tempCourse.type, // 历程状态
                state: tempCourse.state, // 简历状态
                interview_name: tempCourse.interview_name, // 面试官名字
                interview_time: tempCourse.interview_time, // 面试时间
                interTime: tempStr || tempStrs[0], // 面试时间
                interTime1: tempStrs[1] || '', // 面试时间
                interTime2: tempStrs[2] || '', // 面试时间
                mobile: tempCourse.mobile, // 电话
                interview_format: tempCourse.interview_format, // 面试形式
                address: tempCourse.address, // 面试地址
                SInterviewTime: tempCourse.SInterviewTime, // 面试时间， 供应商
                SBackRemark: tempCourse.SBackRemark, // 面试备注， 供应商
                admittime: tempCourse.admittime, // 入场时间
                admitlinkman: tempCourse.admitlinkman, // 入场联系人
                admitmobile: tempCourse.admitmobile, // 入场联系人电话
                proposed_cost: tempCourse.proposed_cost, // 建议成本
                interview_num: tempCourse.interview_num, // 面试轮数
                interview_email: tempCourse.interview_email, // 复试邮箱
                interview_tel: tempCourse.interview_tel, // 服试电话
                interview_remarks: tempCourse.interview_remarks, // 复试备注
                isReexamine: REEXAMINE_STATES[tempCourse.isReexamine].tag, // 是否面试结束, 0:需要复试， 1：面试结束
                reexamineText: REEXAMINE_STATES[tempCourse.isReexamine].text, // 是否面试结束, 0:需要复试， 1：面试结束
                remarks: tempCourse.remarks, // 备注
                sur_name: tempCourse.sur_name, // 反馈人
                update_date: tempCourse.update_date, // 反馈时间
                tempInterviewStusTxt: tempInterviewStusTxt, // 面试安排状态文字
                tempResumeStateTxt: tempResumeStateTxt, // 简历状态文字
                tempInterviewBackTxt: tempInterviewBackTxt, // 面试反馈状态文字
                interviewList: [],
            }
            // if(tempCourse.interviewRecordSupList) {
            //     tempRights.interviewList.push(...tempCourse.interviewRecordSupList)
            // }
            if(tempCourse.interviewRecordList) {
                tempRights.interviewList.push(...tempCourse.interviewRecordList)
            }
            console.log(tempRights.interviewList)
            tempData.push({
                leftDatas: tempLefts,
                details: tempRights
            })
        }
        return tempData;
    }
}
